'''
https://leetcode.cn/problems/best-time-to-buy-and-sell-stock/description/
'''

from typing import List

class Solution:

    # 计算最好的卖的时机
    def maxProfit(self, prices: List[int]) -> int:
        min_price = prices[0]
        max_profit = 0
        for price in prices:
            max_profit = max(max_profit, price - min_price)
            min_price = min(min_price, price)
        return max_profit